#-- base settings --#
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",rxvt-unicode-256color:Tc"
set -sg escape-time 0
set -g display-time 3000
set -g history-limit 65535
set -g base-index 1
set -g pane-base-index 1
set -g renumber-windows on

#-- bindkeys --#
# prefix key (Ctrl+a)
#set -g prefix ^a
#unbind ^b
#bind a send-prefix

# split window
unbind '"'
bind - splitw -v # vertical split (prefix -)
unbind %
bind | splitw -h # horizontal split (prefix |)

# select pane
bind k selectp -U # above (prefix k)
bind j selectp -D # below (prefix j)
bind h selectp -L # left (prefix h)
bind l selectp -R # right (prefix l)

# resize pane
bind -r ^k resizep -U 5 # upward (prefix Ctrl+k)
bind -r ^j resizep -D 5 # downward (prefix Ctrl+j)
bind -r ^h resizep -L 5 # to the left (prefix Ctrl+h)
bind -r ^l resizep -R 5 # to the right (prefix Ctrl+l)

# swap pane
bind ^u swapp -U # swap with the previous pane (prefix Ctrl+u)
bind ^d swapp -D # swap with the next pane (prefix Ctrl+d)

# select layout
bind , select-layout even-vertical
bind . select-layout even-horizontal

# misc
bind e lastp  # select the last pane (prefix e)
bind ^e last  # select the last window (prefix Ctrl+e)
bind q killp  # kill pane (prefix q)
bind ^q killw # kill window (prefix Ctrl+q)

# copy mode
bind Escape copy-mode             # enter copy mode (prefix Escape)
bind ^p pasteb                    # paste buffer (prefix Ctrl+p)
#bind -t vi-copy v begin-selection # select (v) v1.8
#bind -t vi-copy y copy-selection  # copy (y) v1.8
unbind -T copy-mode-vi Space # v2.4+
bind -T copy-mode-vi v send -X begin-selection   # select (v) v2.4+
bind -T copy-mode-vi y send -X copy-pipe "xclip" # copy (y) v2.4+

# app
bind ! splitw htop                                     # htop (prefix !)
bind m command-prompt "splitw 'exec man %%'"           # man (prefix m)
bind % command-prompt "splitw 'exec perldoc -t %%'"    # perl doc (prefix %)
bind / command-prompt "splitw 'exec ri %%'"            # ruby doc (prefix /)

# reload config (prefix r)
bind r source ~/.tmux.conf \; display "Configuration reloaded!"

#-- statusbar --#
set -g status-interval 1
set -g status-keys vi

setw -g mode-keys vi
setw -g automatic-rename off

#-- colorscheme --#

# modes
setw -g clock-mode-colour colour223
set -g mode-style bg=colour235,fg=colour223,bold


# panes
set -g pane-active-border-style bg=default,fg=magenta
set -g pane-border-style fg=green

# statusbar
set -g status-justify right
set -g status-bg colour235
set -g status-fg colour248
set -g status-left ""
set -g status-left-length 20
set -g status-right "#[fg=colour37]#(/usr/local/bin/tm sysinfo) #[default]•"
set -g status-right-length 80

set -g status-style "fg=#504945,bg=#282828"

# window
setw -g window-status-separator " "
setw -g window-status-format "-"
setw -g window-status-current-format "o"
setw -g window-status-current-style "fg=#d79921,bg=#282828"
# pane
#set -g pane-border-style "fg=#ebdbb2"
#set -g pane-active-border-style "fg=#d79921"
#

#setw -g window-status-alert-attr bold
#setw -g window-status-alert-fg colour255
#setw -g window-status-alert-bg colour160

# messages
set -g message-style fg=colour223,bg=colour235,bold
